var consoleSvc = Cc["@mozilla.org/consoleservice;1"].
                 getService(Ci.nsIConsoleService);

function jsdump(str) {
  consoleSvc.logStringMessage(str);
}

var Xmppweb = {
  hello: function () {
    var content = window.content;
    var document = window.content.document;
    var elt = document.createElement('p');
    elt.innerHTML = window.content.location.href;
    document.body.appendChild(elt);
    jsdump('ok');
    this.openwin();
  },
  openwin: function() {
    var w = window.open("","_blank","chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
    w.location.href = "chrome://xmppweb/content/xmppweb.xul";
  },
  saveDoc: function() {
    var persist = Components.classes['@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
                    .createInstance(Components.interfaces.nsIWebBrowserPersist);
    var targetURI = Components.classes['@mozilla.org/network/io-service;1']
                      .getService(Components.interfaces.nsIIOService)
                      .newURI('ftp://localhost/hoge.html', null, null);
    var targetFile = Components.classes['@mozilla.org/file/local;1']
                       .createInstance(Components.interfaces.nsILocalFile);
    targetFile.initWithPath("/home/teruaki/Desktop/hoge.html");
    var dataPath = Components.classes['@mozilla.org/file/local;1']
                       .createInstance(Components.interfaces.nsILocalFile);
    dataPath.initWithPath("/home/teruaki/Desktop/hoge/");
    var dataURI = Components.classes['@mozilla.org/network/io-service;1']
                      .getService(Components.interfaces.nsIIOService)
                      .newURI('ftp://localhost/hoge/', null, null);
    persist.saveDocument(window.content.document,targetURI,dataURI,"text/html; charset=UTF-8",null,null);
  }
};